#!/bin/bash

PARAMETER_2=$2

usage() {
    echo "Usage: sh 执行脚本.sh [mount|all|base|plg|start|stop|stopall|rm]"
    exit 1
}

##放置挂载文件
mount(){
    #挂载 mysql 配置文件
    mkdir -p /techxyz/docker/mysql/conf
    cp -f mysql/conf/my.cnf /techxyz/docker/mysql/conf/my.cnf
    #挂载 redis 配置文件
    mkdir -p /techxyz/docker/redis/conf
    cp -f redis/conf/redis.conf /techxyz/docker/redis/conf/redis.conf
    #挂载 seata 配置文件
    mkdir -p /techxyz/docker/seata/conf
    cp -f seata/conf/application.yml /techxyz/docker/seata/conf/application.yml
    #挂载 rabbitmq 配置文件
    mkdir -p /techxyz/docker/rabbitmq/plugins
    cp -f rabbitmq/plugins/rabbitmq_delayed_message_exchange-3.11.1.ez /techxyz/docker/rabbitmq/plugins/rabbitmq_delayed_message_exchange-3.11.1.ez
    mkdir -p /techxyz/docker/rabbitmq/data
    #挂载 elasticsearch 配置文件
    mkdir -p /techxyz/docker/es/conf
    mkdir -p /techxyz/docker/es/data
    mkdir -p /techxyz/docker/es/plugins
    cp -f es/conf/elasticsearch.yml /techxyz/docker/es/conf/elasticsearch.yml
    #挂载 kibana 配置文件
    mkdir -p /techxyz/docker/kibana/conf
    cp -f kibana/conf/kibana.yml /techxyz/docker/kibana/conf/kibana.yml
    #挂载 minio 配置文件
    mkdir -p /techxyz/docker/minio/data
    mkdir -p /techxyz/docker/minio/conf
    #挂载 plg 配置文件
    mkdir -p /techxyz/docker/plg/loki/conf
    cp -f plg/loki/conf/loki-local-config.yaml /techxyz/docker/plg/loki/conf/loki-local-config.yaml
    mkdir -p /techxyz/docker/plg/promtail/conf
    cp -f plg/promtail/conf/promtail-local-config.yaml /techxyz/docker/plg/promtail/conf/promtail-local-config.yaml
    #挂在 nginx 配置文件
    mkdir -p /techxyz/docker/nginx
    cp -rf nginx/. /techxyz/docker/nginx/
    #全部授权
    chmod 777 -R /techxyz
}

#根据输入参数，选择执行对应方法，不输入则执行使用说明
case "$1" in
"mount")
    mount
;;
*)
    usage
;;
esac
